package service;

import domain.Player;

public class SettlementSercive {

    /**
     * 负责人:阿旻
     * 功能:根据属性选择,生成评价
     * 返回值:String
     * 参数:Player player
     */
    public static String getEvaluate(Player player){
        StringBuilder evaluate = new StringBuilder();
        int iq = player.getIq();
        int pf = player.getPf();
        int fs = player.getFs();
        int ffs = player.getFfs();
        int luck = player.getLuck();
        int age = player.getDeathAge();
        String[] iqs ={"卧龙凤雏","智力中等","足智多谋"};
        String[] pfs ={"体弱多病","健康无恙","身强体壮"};
        String[] fss ={"不忍直视","长相周正","天生丽质"};
        String[] ffss ={"家境贫寒","家庭和睦","家境优渥"};
        String[] lucks ={"喝凉水都塞牙","运气一般","好运连连"};
        String[] ages ={"英年早逝","寿终正寝","人生无憾"};
        evaluate.append("智力:");
        getEvery(iq,evaluate,iqs);
        evaluate.append(",体质:");
        getEvery(pf,evaluate,pfs);
        //换行
        evaluate.append(System.lineSeparator());
        evaluate.append("颜值:");
        getEvery(fs,evaluate,fss);
        evaluate.append(",家境:");
        getEvery(ffs,evaluate,ffss);
        evaluate.append(System.lineSeparator());
        evaluate.append("运气:");
        getEvery(luck,evaluate,lucks);
        evaluate.append(",寿命:");
        getEvery(age/10,evaluate,ages);
        return evaluate.toString();
    }

    private static void getEvery(int number, StringBuilder sb, String[] arr){
        if(number <= 2){
            sb.append(arr[0]);
        }else if(number <= 8){
            sb.append(arr[1]);
        }else {
            sb.append(arr[2]);
        }
    }

    public static String getAchievement(Player player){
        StringBuilder achievement = new StringBuilder();
        int iq = player.getIq();
        int pf = player.getPf();
        int fs = player.getFs();
        int ffs = player.getFfs();
        int luck = player.getLuck();
        int age = player.getDeathAge();
        String[] iqs ={"呆呆傻傻 ","聪明绝顶 ","    "};
        String[] pfs ={"弱不禁风 ","钢铁身躯 ","    "};
        String[] fss ={"不像个人 ","风流倜傥 ","    "};
        String[] ffss ={"家道中落 ","家财万贯 ","    "};
        String[] lucks ={"厄运缠身 ","时来运转 ","    "};
        String[] ages ={"天妒英才 ","寿比南山 ","    "};

        achievement.append(getAchievement(iq,iqs));
        achievement.append(getAchievement(pf,pfs));
        achievement.append(getAchievement(fs,fss));
        achievement.append(System.lineSeparator());
        achievement.append(getAchievement(ffs,ffss));
        achievement.append(getAchievement(luck,lucks));
        achievement.append(getAchievement(age/10,ages));


        return achievement.toString();
    }

    private static String getAchievement(int number, String[] arr){
        if(number <= 2){
            return arr[0];
        }else if(number >= 8){
            return arr[1];
        }
        return arr[2];
    }
}
